package net.lzzy.practicesapi1.entities;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.util.UUID;

@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)//生成无参构造器
@MappedSuperclass
public class BaseEntity {
    //使用uuid2类型作为自动生成主键值的生成器
    //指定UUID的生成策略，与上一个注解搭配，二者缺一不可
    @Id
    @GeneratedValue(generator = "uuid2")
    @GenericGenerator(name = "uuid2",strategy = "uuid2")
    @Column(columnDefinition = "BINARY(16)")
    protected UUID id;

    @Column(nullable = false)
    protected boolean open;

    //protected   BaseEntity(){}
}
